<%@ page import="ingresso.Evento" %>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<g:set controller="Evento" var="entityName" value="${message(code: 'evento.label', default: 'Evento')}" />
		<meta name="layout" content="main"/>
		<title>Ingresso.Bom</title>
		<style type="text/css" media="screen">
			#status {
				background-color: #eee;
				border: .2em solid #fff;
				margin: 2em 2em 1em;
				padding: 1em;
				width: 12em;
				float: left;
				-moz-box-shadow: 0px 0px 1.25em #ccc;
				-webkit-box-shadow: 0px 0px 1.25em #ccc;
				box-shadow: 0px 0px 1.25em #ccc;
				-moz-border-radius: 0.6em;
				-webkit-border-radius: 0.6em;
				border-radius: 0.6em;
			}

			.ie6 #status {
				display: inline; /* float double margin fix http://www.positioniseverything.net/explorer/doubled-margin.html */
			}

			#status ul {
				font-size: 0.9em;
				list-style-type: none;
				margin-bottom: 0.6em;
				padding: 0;
			}
            
			#status li {
				line-height: 1.3;
			}

			#status h1 {
				text-transform: uppercase;
				font-size: 1.1em;
				margin: 0 0 0.3em;
			}

			#page-body {
				margin: 2em 1em 1.25em 18em;
			}

			h2 {
				margin-top: 1em;
				margin-bottom: 0.3em;
				font-size: 1em;
			}

			p {
				line-height: 1.5;
				margin: 0.25em 0;
			}

			#controller-list ul {
				list-style-position: inside;
			}

			#controller-list li {
				line-height: 1.3;
				list-style-position: inside;
				margin: 0.25em 0;
			}

			@media screen and (max-width: 480px) {
				#status {
					display: none;
				}

				#page-body {
					margin: 0 1em 1em;
				}

				#page-body h1 {
					margin-top: 0;
				}
			}
		</style>
	</head>
	<body>			
		<div id="list-evento" class="content scaffold-list" role="main">
			<h1><g:message code="Próximos Eventos..." args="[entityName]" /></h1>
			<g:if test="${flash.message}">
			<div class="message" role="status">${flash.message}</div>
			</g:if>
			<table>
				<thead>
					<tr>
						<th><g:message code="evento.categoria.label" default="Categoria" /></th>
						<th><g:message code="evento.nome.label" default="Nome" /></th>
						<th><g:message code="evento.data.label" default="Data" /></th>
						<th><g:message code="evento.valor.label" default="Valor" /></th>						
						<th></th>			
					</tr>
				</thead>
				<tbody>
				<g:each in="${Evento.list()}" status="i" var="eventoInstance">	
					<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
					
						<td>${fieldValue(bean: eventoInstance, field: "categoria.tipo")}</td>
						
						<td>${fieldValue(bean: eventoInstance, field: "nome")}</td>
					
						<td><g:formatDate date="${eventoInstance.data}" type="date" /></td>
					
						<td><g:formatNumber number="${eventoInstance.valor}" type="currency"/></td>																		
						
						<td><g:link class="create" action="create" controller="ingresso" id="${eventoInstance?.id}">Comprar Ingresso</g:link></td>					
					</tr>
				</g:each>
				</tbody>
			</table>
		</div>

			<g:form method="post" action="pesquisar" controller="evento">
				<g:hiddenField name="id" value="${eventoInstance?.id}" />
				<g:hiddenField name="version" value="${eventoInstance?.version}" />
				<fieldset class="form">
					<div class="fieldcontain ${hasErrors(bean: eventoInstance, field: 'data', 'error')} ">
						<label for="data">
							<g:message code="evento.data.label" default="Data" />
							<span class="required-indicator">*</span>
						</label>
						<g:datePicker name="data" precision="day"  value="${eventoInstance?.data}" />
					</div>
					
					<div class="fieldcontain ${hasErrors(bean: eventoInstance, field: 'descricao', 'error')} ">
						<label for="descricao">
							<g:message code="evento.descricao.label" default="Descricao" />
							<span class="required-indicator">*</span>
						</label>
						<g:textField name="descricao" value="${eventoInstance?.descricao}" />
					</div>
					
					<div class="fieldcontain ${hasErrors(bean: eventoInstance, field: 'categoria', 'error')} ">
						<label for="categoria">
							<g:message code="evento.categoria.label" default="Categoria" />
							<span class="required-indicator">*</span>
						</label>
						<g:select id="categoria" name="categoria.id" from="${ingresso.Categoria.list()}" noSelection="${['null':'Selecione uma Categoria...']}" optionKey="id" optionValue="tipo" value="${eventoInstance?.categoria?.id}" class="many-to-one"/>
					</div>
					
					<div class="fieldcontain ${hasErrors(bean: eventoInstance, field: 'cidade', 'error')} ">
						<label for="cidade">
							<g:message code="evento.cidade.label" default="Cidade" />
							<span class="required-indicator">*</span>
						</label>
						<g:select id="cidade" name="cidade.id" from="${ingresso.Cidade.list()}" noSelection="${['null':'Selecione uma Cidade...']}" optionKey="id" optionValue="nome" value="${eventoInstance?.cidade?.id}" class="many-to-one"/>
					</div>
				</fieldset>
				<fieldset class="buttons">
					<g:actionSubmit class="list" action="pesquisar" value="Pesquisar" />
				</fieldset>
			</g:form>	
	</body>
</html>
